
package Componentes;


import java.awt.Component;
import java.awt.event.ActionEvent;
import java.awt.event.ActionListener;
import javax.swing.AbstractAction;
import javax.swing.AbstractCellEditor;
import javax.swing.JButton;
import javax.swing.JTable;
import javax.swing.table.TableCellEditor;


public class ButtonEditor extends AbstractCellEditor implements TableCellEditor,ActionListener{
    protected JButton button;
    protected Object valor="";
    private AbstractAction accion;

    public ButtonEditor() {
    }
    
    
    
    public ButtonEditor(AbstractAction accion){
        this.accion=accion;

    }

    @Override
    public void actionPerformed(ActionEvent ae) {
       fireEditingStopped();
    }

    @Override
    public Object getCellEditorValue() {
        return this.valor;
    }
    
    @Override
   public Component getTableCellEditorComponent(JTable table, Object value, boolean isSelected, int row, int column){
        this.valor=value;
        button = new JButton(getAccion());
        button.addActionListener(this);
        button.setBorderPainted(true);
        return  button;

   }

  
    public AbstractAction getAccion() {
        return accion;
    }

  
    public void setAccion(AbstractAction accion) {
        this.accion = accion;
    }

}
